import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_kit_plus/flutter_kit.dart';
import 'package:provider/provider.dart';

import '../class/notifier.dart';
import '../tool/tool.dart';
import 'home.dart';

Future<void> main() async {
  /// 捕获所有未捕获的 Dart 异常
  LogManager.initFireBase(runMain: () async {
    // BluetoothManagerWithAutoConnect = false;
    BluetoothManager.instance.requestPermissions();
    runApp(
      MultiProvider(
        providers: [
          ChangeNotifierProvider(create: (context) => DeviceConnectStateNotifier()),
          ChangeNotifierProvider(create: (context) => LogNotifier()),
        ],
        child: const MyApp(),
      ),
    );
  });
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'EZ OTA',
      navigatorKey: navigatorKey,
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        // colorScheme: ColorScheme.fromSeed(seedColor: Colors.white),
        // useMaterial3: true,

        // ///自定义主题颜|色
        // primaryColor: Colors.white,

        // ///自定义亮/暗主题
        // brightness: Brightness.light,

        // ///自定义appbar 颜色
        // appBarTheme: const AppBarTheme(
        //   color: Colors.white,
        // ),

        // ///自定义按钮主题
        // buttonTheme: const ButtonThemeData(
        //   buttonColor: Colors.white,
        //   textTheme: ButtonTextTheme.primary,
        // ),

        ///自定义文本主题
        // textTheme: const TextTheme(
        //   bodyText1: TextStyle(color: Color(0x00436FEB)),
        //   bodyText2: TextStyle(color: Colors.grey),
        // ),
        floatingActionButtonTheme: const FloatingActionButtonThemeData(
          backgroundColor: Colors.white,
        ),
      ),
      home: const MyHomePage(title: 'Connect'),
      builder: EasyLoading.init(),
      // home: ImageGradientTransition(),
    );
  }
}
